﻿using System;

namespace Actya.Core.Infrastructure.Logging
{
	/// <summary>
	/// Factory that creates loggers. You can configure the type of logger to set the GetLogger delegate 
	/// to return the desired type.
	/// </summary>
	public static class LogManager
	{
		static readonly ILogger NullLogInstance = new NullLogger();

		/// <summary>
		/// Creates an <see cref="ILogger"/> for the provided type.
		/// </summary>
		public static Func<Type, ILogger> GetLogger = type => NullLogInstance;

		/// <summary>
		/// Default logger that does nothing.
		/// </summary>
		private class NullLogger : ILogger
		{
			public void Debug(string format, params object[] args) { }
			public bool IsDebugEnabled { get { return false; } }
			public void Info(string format, params object[] args) { }
			public void Warn(string format, params object[] args) { }
			public void Error(string format, params object[] args) { }
			public void Error(Exception exception) { }
		}
	}
}
